<?php

namespace App\Console\Commands;

use Carbon\Carbon;
use Illuminate\Console\Command;
use QL\QueryList;
use GuzzleHttp\Exception\RequestException;
use Illuminate\Support\Facades\Storage;
use GuzzleHttp\Client;
use Illuminate\Support\Str;
use QL\Ext\Chrome;

class PostCommand extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'command:name';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        ini_set('error_reporting', 0);
        ini_set('memory_limit', '5120M');
        error_reporting(0);
        $ql = QueryList::getInstance();
        $ql->use(Chrome::class);

        //注册一个myGet方法到QueryList对象
        $ql->bind('myGet', function ($url, $args = null, $otherArgs = []) {
            try {
                $this->get($url, $args, $otherArgs);
                //$this->chrome($url);
            } catch (RequestException $e) {
                $this->setHtml('');
                // print_r($e->getRequest());
            }
            return $this;
        });
    }
}
